## Replication Code for 
##
## Moore, Ryan T., Eleanor Neff Powell, and Andrew Reeves. "Driving Support:
## Workers, PACs, and Congressional Support of the Auto Industry". Business and
## Politics, 15(2):137-162, 2013.
##
## 1 September 2013

## Load libraries:
library(apsrtable) ## 0.8-8
library(plyr)  ## 1.8
library(Zelig) ## 3.5.5

## Load two data objects:
load("data/autoFull4.RData")
## Load replication functions:
source("code/replicationFuncs.R")

## Cut duplicate districts in the data so that district counts are correct below:
adat <- cut.func(c("IL14", "LA6", "MS1"), c(200, 200, 200), vec.spec.congress = c(110, 110, 110), vec.spec.same = c("CA12", "CA37", "CA5", "GA10", "IN7", "LA1", "MA5", "MD4", "OH11", "OH5", "VA1"), vec.spec.same.which = c(1,1,1,2,2,1,1,2,2,1,1), vec.spec.same.congress = rep(110, 11), data = adat)
adat <- cut.func(vec.spec.same = "IN7", vec.spec.same.which = 2, vec.spec.same.congress = 110, data = adat)

## Cut duplicate districts in the data so that district counts are correct below:
adat <- cut.func(c("AL5", "HI1", "NY23", "NY29"), c(200, 200, 100, 200), vec.spec.congress = rep(111,4), vec.spec.same = c("CA10", "CA32", "FL19", "FL9", "GA9", "IN3", "NY20", "PA12"), vec.spec.same.which = c(rep(1, 5), 2, 1, 1), vec.spec.same.congress = rep(111, 8), data = adat)
adat <- cut.func(vec.spec.same = "AL5", vec.spec.same.which = 1, vec.spec.same.congress = 111, data = adat)

## Create data subsets by Congress and party for later calculations:
adat110 <- adat[(adat$congress == 110),]
adat111 <- adat[(adat$congress == 111),]
adat110r <- adat110[adat110$party == 200,]
adat110d <- adat110[adat110$party == 100,]
adat111r <- adat111[adat111$party == 200,]
adat111d <- adat111[adat111$party == 100,]

## Calculations of industry presence that appear on roughly page 145:
length(unique(adat110$stcd[(adat110$factory.s2 > 0)]))
length(unique(adat110r$stcd[(adat110r$factory.s2 > 0)]))
length(unique(adat110d$stcd[(adat110d$factory.s2 > 0)]))
length(unique(adat110$stcd[(adat110$n100_249.s2 > 0) | (adat110$n250_499.s2 > 0) | (adat110$n500_999.s2 > 0) | (adat110$n1000.s2 > 0)]))/435
length(unique(adat110$stcd[(adat110$n10_19.s2 > 0) | (adat110$n20_49.s2 > 0) | (adat110$n50_99.s2 > 0) | (adat110$n100_249.s2 > 0) | (adat110$n250_499.s2 > 0) | (adat110$n500_999.s2 > 0) | (adat110$n1000.s2 > 0)]))/435
length(unique(adat110$stcd[(adat110$n1_4.s2 > 0) | (adat110$n5_9.s2 > 0) | (adat110$n10_19.s2 > 0) | (adat110$n20_49.s2 > 0) | (adat110$n50_99.s2 > 0) | (adat110$n100_249.s2 > 0) | (adat110$n250_499.s2 > 0) | (adat110$n500_999.s2 > 0) | (adat110$n1000.s2 > 0)]))/435

## Calculations of industry presence that appear on roughly page 146:
y110 <- (adat110$factory.s2 > 0)
n111 <- (adat111$factory.s1 == 0)
n110 <- (adat110$factory.s2 == 0)
y111 <- (adat111$factory.s1 > 0)

lost.fac <- unique(adat110$stcd[y110])[unique(adat110$stcd[y110]) %in% unique(adat111$stcd[n111])]
sort(unique(adat110$state.abb[adat110$stcd %in% lost.fac]))

length(unique(adat111$stcd[(adat111$factory.s1 > 0)]))
length(unique(adat111r$stcd[(adat111r$factory.s1 > 0)]))
length(unique(adat111d$stcd[(adat111d$factory.s1 > 0)]))

## Summary calculations regarding contributions:
summary(exp(adat$Total.FordDCGM.log)-1)
mean(exp(adat$Total.FordDCGM.log)-1 ==0)
summary(adat$Total.FordDCGM.log)

tmp <- matrix(c(sum(adat110$Total.FordDCGM.log[(adat110$factory.s1 > 0) | (adat110$factory.s2 > 0)]==0), 
                sum(adat110$Total.FordDCGM.log[(adat110$factory.s1 > 0) | (adat110$factory.s2 > 0)]!=0), 
                sum(adat110$Total.FordDCGM.log[(adat110$factory.s1 == 0) & (adat110$factory.s2 == 0)] == 0),
                sum(adat110$Total.FordDCGM.log[(adat110$factory.s1 == 0) | (adat110$factory.s2 == 0)] !=0)), 2, 2, byrow = TRUE)
prop.test(tmp)
## among districts with nonzero Big Three PAC contribs, 
qqplot(adat110$Total.FordDCGM.log[(adat110$Total.FordDCGM.log !=0) & (adat110$factory.s1 > 0 | adat110$factory.s2 > 0)],
       adat110$Total.FordDCGM.log[adat110$Total.FordDCGM.log !=0 & (adat110$factory.s1 == 0 & adat110$factory.s2 == 0)], 
       ylab = "Big 3 Contribs (log), No Factory", xlab = "Big 3 Contribs (log), Factory", xlim = c(5,11), ylim=c(5,11))
abline(0,1)

rm(adat110, adat110d, adat110r, adat111, adat111r, adat111d, y110, n111, lost.fac, tmp, cut.func)


## Multivariate Models

## Paper table 2, bailout:
regressBillsAFL("vote.rc110.2.690", adat, exclude.cells = 1, lopsided = 1, tables = TRUE)
## Paper table 3, clunkers:
regressBillsAFL("vote.rc111.1.314", adat, exclude.cells = 1, lopsided = 1, tables = TRUE)


## QoI, vote 690
x.seq <- seq(0, 10, by = .25)
z.out <- zelig(vote.rc110.2.690 ~ factory.s2 + dwnom1 + Total.FordDCGM.log + Total.AFL.CIO.log, model = "logit", data = adat)
x.lo <- setx(z.out, factory.s2 = 0, Total.FordDCGM.log = x.seq)  ## all others at mean
x.hi <- setx(z.out, factory.s2 = 1, Total.FordDCGM.log = x.seq)  ## all others at mean
s.out <- sim(z.out, x = x.lo, x1 = x.hi)
jit <- jitter(adat$Total.FordDCGM.log, factor = 70)
## Figure 2, left panel:
plot.ci(s.out, CI= 95, qi="fd", ylim=c(-.4,.4), xlab="Total Big 3 PAC Contributions (log)", main="Bailout", ylab = "First Diffs, Industry (minus) No Industry")
points(x = x.seq, y = apply(s.out$qi$fd, 2, mean), pch = 19)
abline(h=0, col = "grey", lty = 2)
rug(jit[(adat$party == 100) & (adat$vote.rc110.2.690==1)], col = "blue", ticksize = .1, pos=-.23)
rug(jit[(adat$party == 200) & (adat$vote.rc110.2.690==0)], col = "red", ticksize = .1)
rug(jit[(adat$party == 100) & (adat$vote.rc110.2.690==0)], col = "lightblue", ticksize = .1, pos=-.33)
rug(jit[(adat$party == 200) & (adat$vote.rc110.2.690== 1)], col = "pink", ticksize = .1, pos=-.33)

xlabtext <- "Difference in Predicted Probability of 'Yes' Vote"

x.lo <- setx(z.out, factory.s2 = 0) ## all others at mean
x.hi <- setx(z.out, factory.s2 = 1) ## all others at mean
s.out <- sim(z.out, x = x.lo, x1 = x.hi, num = 5000)
## Figure 1, top row, left panel:
plot(density(s.out$qi$fd), main="Industry minus Non-Industry, Bailout support", xlim=c(-.12, .6), xlab = xlabtext)
abline(v=0, col="grey", lty=2)

x.lo <- setx(z.out, factory.s2 = 0, Total.FordDCGM.log = 0) ## all others at mean
x.hi <- setx(z.out, factory.s2 = 0, Total.FordDCGM.log = median(adat$Total.FordDCGM.log[adat$Total.FordDCGM.log > 0])) ## all others at mean
s.out <- sim(z.out, x=x.lo, x1=x.hi, num=5000)
## Figure 1, middle row, left panel:
plot(density(s.out$qi$fd), main="High minus No Big 3 Contribs, Bailout support, No Industry", xlim=c(-.12, .6), xlab = xlabtext)
abline(v = 0, col="grey", lty=2)

x.lo <- setx(z.out, factory.s2 = 0, Total.AFL.CIO.log = 0) ## all others at mean
x.hi <- setx(z.out, factory.s2 = 0, Total.AFL.CIO.log = median(adat$Total.AFL.CIO.log[adat$Total.AFL.CIO.log > 0])) ## all others at mean
s.out <- sim(z.out, x=x.lo, x1=x.hi, num=5000)
## Figure 1, bottom row, left panel:
plot(density(s.out$qi$fd), main="High minus No AFL-CIO Contribs, Bailout support, No Industry", xlim=c(-.12, .6), xlab = xlabtext)
abline(v=0, col="grey", lty=2)


## QoI, vote 314
x.seq <- seq(0, 10, by = .25)
z.out <- zelig(vote.rc111.1.314 ~ factory.s1 + dwnom1 + Total.FordDCGM.log + Total.AFL.CIO.log, model = "logit", data = adat)
x.lo <- setx(z.out, factory.s1 = 0, Total.FordDCGM.log = x.seq) ## all others at mean
x.hi <- setx(z.out, factory.s1 = 1, Total.FordDCGM.log = x.seq) ## all others at mean
s.out <- sim(z.out, x = x.lo, x1 = x.hi)
jit <- jitter(adat$Total.FordDCGM.log, factor =100)
## Figure 2, right panel:
plot.ci(s.out, CI= 95, qi="fd", ylim=c(-.4,.4), xlab="Total Big 3 PAC Contributions (log)", main="Cash for Clunkers", ylab = "First Diffs, Industry (minus) No Industry")
points(x = x.seq, y = apply(s.out$qi$fd, 2, mean), pch = 19)
abline(h=0, col="grey", lty=2)
rug(jit[adat$party == 100 & adat$vote.rc111.1.314 == 1], col = "blue", ticksize = .1, pos=-.23)
rug(jit[(adat$party == 200) & (adat$vote.rc111.1.314 == 0)], col = "red", ticksize = .1)
rug(jit[(adat$party == 100) & (adat$vote.rc111.1.314==0)], col = "lightblue", ticksize = .1, pos=-.33)
rug(jit[(adat$party == 200) & (adat$vote.rc111.1.314== 1)], col = "pink", ticksize = .1, pos=-.33)

x.lo <- setx(z.out, factory.s1 = 0) ## all others at mean
x.hi <- setx(z.out, factory.s1 = 1) ## all others at mean
s.out <- sim(z.out, x=x.lo, x1=x.hi, num=5000)
## Figure 1, top row, right panel:
plot(density(s.out$qi$fd), main="Industry minus Non-Industry, Clunkers support", xlim=c(-.12, .6), xlab = xlabtext)
abline(v=0, col="grey", lty=2)

x.lo <- setx(z.out, factory.s1 = 0, Total.FordDCGM.log = 0) ## all others at mean
x.hi <- setx(z.out, factory.s1 = 0, Total.FordDCGM.log = median(adat$Total.FordDCGM.log[adat$Total.FordDCGM.log > 0])) ## all others at mean
s.out <- sim(z.out, x=x.lo, x1=x.hi, num=5000)
## Figure 1, middle row, right panel:
plot(density(s.out$qi$fd), main="High minus No Big 3 Contribs, Clunkers support, No Industry", xlim=c(-.12, .6), xlab = xlabtext)
abline(v=0, col="grey", lty=2)

x.lo <- setx(z.out, factory.s1 = 0, Total.AFL.CIO.log = 0) ## all others at mean
x.hi <- setx(z.out, factory.s1 = 0, Total.AFL.CIO.log = median(adat$Total.AFL.CIO.log[adat$Total.AFL.CIO.log > 0])) ## all others at mean
s.out <- sim(z.out, x=x.lo, x1=x.hi, num=5000)
## Figure 1, bottom row, right panel:
plot(density(s.out$qi$fd), main="High minus No AFL-CIO Contribs, Clunkers support, No Industry", xlim=c(-.12, .6), xlab = xlabtext)
abline(v=0, col="grey", lty=2)

x.seq <- seq(-1, 1.25, by = .05)
z.out <- zelig(vote.rc110.2.690 ~ factory.s2 + dwnom1 + Total.FordDCGM.log + Total.AFL.CIO.log, model = "logit", data = adat)
x.lo <- setx(z.out, factory.s2 = 0, dwnom1 = x.seq)  ## all others at mean
x.hi <- setx(z.out, factory.s2 = 1, dwnom1 = x.seq)  ## all others at mean
s.out <- sim(z.out, x = x.lo, x1 = x.hi)
## Figure 3, left panel:
plot.ci(s.out, CI= 95, qi="fd", ylim=c(-.5,.5), xlab="DW-NOMINATE Score, first dimension", main = "Bailout", ylab = "First Diffs, Industry (minus) No Industry")
points(x = x.seq, y = apply(s.out$qi$fd, 2, mean), pch = 20)
abline(h=0, col = "grey", lty = 2)
rug(jitter(adat$dwnom1[adat$party == 100 & adat$vote.rc110.2.690 == 1]), col = "blue", ticksize = .1)
rug(jitter(adat$dwnom1[(adat$party == 200) & (adat$vote.rc110.2.690 == 0)]), col = "red", ticksize = .1)
rug(jitter(adat$dwnom1[(adat$party == 100) & (adat$vote.rc110.2.690 == 0)]), col = "purple", ticksize = .1, pos=-.42)
rug(jitter(adat$dwnom1[(adat$party == 200) & (adat$vote.rc110.2.690 == 1)]), col = "purple", ticksize = .1, pos=-.42)

z.out <- zelig(vote.rc111.1.314 ~ factory.s1 + dwnom1 + Total.FordDCGM.log + Total.AFL.CIO.log, model = "logit", data = adat)
x.seq <- seq(-1, 1.3, by = .05)
x.lo <- setx(z.out, factory.s1 = 0, dwnom1 = x.seq)  ## all others at mean
x.hi <- setx(z.out, factory.s1 = 1, dwnom1 = x.seq)  ## all others at mean
s.out <- sim(z.out, x = x.lo, x1 = x.hi)
## Figure 3, right panel:
plot.ci(s.out, CI= 95, qi="fd", ylim=c(-.5,.5), xlab="DW-NOMINATE Score, first dimension", main = "Cash for Clunkers", ylab = "First Diffs, Industry (minus) No Industry")
points(x = x.seq, y = apply(s.out$qi$fd, 2, mean), pch = 20)
abline(h=0, col = "grey", lty = 2)
rug(jitter(adat$dwnom1[(adat$party == 100) & (adat$vote.rc111.1.314 == 0)]), col = "purple", ticksize = .1, pos=-.42)
rug(jitter(adat$dwnom1[(adat$party == 200) & (adat$vote.rc111.1.314 == 1)]), col = "purple", ticksize = .1, pos=-.42)
rug(jitter(adat$dwnom1[adat$party == 100 & adat$vote.rc111.1.314 == 1]), col = "blue", ticksize = .1)
rug(jitter(adat$dwnom1[(adat$party == 200) & (adat$vote.rc111.1.314 == 0)]), col = "red", ticksize = .1)


## Regress all votes on factory, Big 3, etc.
vote.names.110.12.111.1 <- names(adat)[c(grep("vote.rc110", names(adat)), grep("vote.rc111.1.", names(adat)))]
out.afl <- regressBillsAFL(vote.names.110.12.111.1, adat, exclude.cells = 1, lopsided = .65)

## define importance groups over which to regress
imp.bills.small <- imp.bills[!(is.na(imp.bills$roll)), ]
impYes <- imp.bills.small$rcname[apply(imp.bills.small[, c("big3", "ford", "gm", "chrysler", "aam")], 1, sum) > 0]
impYes <- impYes[impYes %in% vote.names.110.12.111.1]
impNo <- vote.names.110.12.111.1[!(vote.names.110.12.111.1 %in% impYes)]

out.afl$lobbied[out.afl$vote %in% impYes] <- "Lobbied"
out.afl$lobbied[out.afl$vote %in% impNo] <- "Not Lobbied"
out.afl$lobbied <- as.factor(out.afl$lobbied)

rm(imp.bills)

set.seed(720)
st.normal <- rnorm(300)
lll <- 3.5
## Figure 4, left panel:
qqplot(out.afl$factory[out.afl$lobbied=="Lobbied" & abs(out.afl$factory) < 1000], st.normal,
       xlim=c(-lll, lll), ylim=c(-lll,lll), xlab = "Industry Presence Coefficients, Lobbied Bills",
       ylab = bquote("N(0,1) Values"))
abline(0,1, col="black")
text(-2.2, -3.1, "Normal Dist'n (no systematic influence)", pos = 4)
arrows(-2.1, -3, -2.7, -2.8, length = .1)
text(-1.5, -2.5, "Bimodal Dist'n (pervasive influence)", pos = 4)
arrows(-1.4, -2.4, -1.55, -2.05, length = .1)
par(new = TRUE)
n <- 10000
m1 <- -2
m2 <- 2
s1 <- s2 <- .5
y1 <- rnorm(n, m1, s1)
y2 <- rnorm(n, m2, s2)
pick <- rbinom(n, 1, prob = c(.5,.5))
y <- y1*pick + y2*(1-pick)
plot(sort(y), lty = 2, type = "l", col = "grey", ylim = c(-lll, lll), ylab = "", xlab = "", axes = FALSE)

set.seed(663)
st.normal <- rnorm(300)
lll <- 5
## Figure 4, right panel:
qqplot(out.afl$lBig3[out.afl$lobbied=="Lobbied" & abs(out.afl$lBig3) < 1000], st.normal,
       xlim=c(-lll, lll), ylim=c(-lll,lll), xlab = "(log) Big 3 Contribution Coefficients, Lobbied Bills",
       ylab = bquote("N(0,1) Values"))
abline(0,1, col="black")
text(-2.2, -3.2, "Normal Dist'n (no systematic influence)", pos = 4)
arrows(-2.1, -3.1, -2.7, -2.8, length = .1)
text(-1.5, -2.5, "Bimodal Dist'n (pervasive influence)", pos = 4)
arrows(-1.4, -2.4, -1.5, -1.9, length = .1)
par(new = TRUE)
plot(sort(y), lty = 2, type = "l", col = "grey", ylim = c(-lll, lll), ylab = "", xlab = "", axes = FALSE)

rm(n, m1, m2, s1, s2, y1, y2, pick, y)

## Fractions w/in 2 SDs:
mean(abs(out.afl$factory[out.afl$lobbied=="Lobbied"]) < 2)
mean(abs(out.afl$lBig3[out.afl$lobbied=="Lobbied"]) < 2)


## Position-taken bills:
## Supplementary Tables S1-S8
mapl.data <- read.csv("data/positionsbills.csv")
mapl.names <- as.character(mapl.data$rccode[(mapl.data$onpassage %in% 1) & !((mapl.data$congress %in% 111) & (mapl.data$session %in% 2))])
out.mapl <- regressBillsAFL(mapl.names, adat, exclude.cells = 1, lopsided = 1, include.factory = TRUE, tables = TRUE)


## All Roll Calls
### Regress all votes on factory, Big 3, etc.
vote.names.110.12.111.1 <- names(adat)[c(grep("vote.rc110", names(adat)), grep("vote.rc111.1.", names(adat)))]
out.afl <- regressBillsAFL(vote.names.110.12.111.1, adat, exclude.cells = 1, lopsided = 1)
## Supplementary Figure S1:
plot(density(out.afl$factory, from = -5, to = 5), xlim=c(-5,5), xlab = "Coefficient on Industry Presence", main = "")
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc110.2.690"]) ## .69
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc111.1.314"]) ## .45
## alt: 1 defector
out.afl <- regressBillsAFL(vote.names.110.12.111.1, adat, exclude.cells = 2, lopsided = 1)
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc110.2.690"]) ## .76
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc111.1.314"]) ## .49
## alt: thresholds
out.afl <- regressBillsAFL(vote.names.110.12.111.1, adat, exclude.cells = 1, lopsided = .9)
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc110.2.690"]) ## .76
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc111.1.314"]) ## .49
out.afl <- regressBillsAFL(vote.names.110.12.111.1, adat, exclude.cells = 1, lopsided = .8)
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc110.2.690"]) ## .74
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc111.1.314"]) ## .46
out.afl <- regressBillsAFL(vote.names.110.12.111.1, adat, exclude.cells = 1, lopsided = .7)
mean(abs(out.afl$factory) <= out.afl$factory[out.afl$vote %in% "vote.rc110.2.690"]) ## .70


## Supplement All possible regression specifications

## Load functions:
source("code/regressAll.R")
source("code/regressAllExtract.R")
source("code/regressAllExtractPlot.R")

## create logged minor and unlogged Big 3 PAC variables:
adat$Total.AutomotiveFree.log <- log(adat$Total.AutomotiveFree +1)
adat$Total.Dealers.log <- log(adat$Total.Dealers +1)
adat$Total.DealersForeign.log <- log(adat$Total.DealersForeign +1)
adat$Total.AutoDealersandDrivers.log <- log(adat$Total.AutoDealersandDrivers +1)
adat$Total.FordDCGM <- exp(adat$Total.FordDCGM.log)-1

## Bailout, DW, logged Contribs.
all690pacLog <- regressAll("vote.rc110.2.690", dat = adat, model = "logit", alwaysInclude = c("factory.s2", "dwnom1"), covars = c("factory.s2", "dwnom1", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log"))
var.nms <- c("(Intercept)", "factory.s2", "dwnom1", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log")
coefs690log <- extractor(all690pacLog, var.nms = var.nms)
## Supplementary Figure S2:
plot.extracted(coefs690log, mfrows = c(3,3), pretty.names = c("Auto Workers", "Ideology", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all690pacLog, coefs690log)

## Bailout, DW, dollar contribs.
all690pac <- regressAll("vote.rc110.2.690", dat = adat, model = "logit", alwaysInclude = c("factory.s2", "dwnom1"), covars = c("factory.s2", "dwnom1", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions"))
var.nms <- c("(Intercept)", "factory.s2", "dwnom1", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions")
coefs690 <- extractor(all690pac, var.nms = var.nms)
## Supplementary Figure S3:
plot.extracted(coefs690, mfrows = c(3,3), pretty.names = c("Auto Workers", "Ideology", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all690pac, coefs690)

## Bailout, party, logged Contribs.
all690pacLog <- regressAll("vote.rc110.2.690", dat = adat, model = "logit", alwaysInclude = c("factory.s2", "I(as.factor(party))"), covars = c("factory.s2", "I(as.factor(party))", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log"))
var.nms <- c("(Intercept)", "factory.s2", "I(as.factor(party))200", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log")
coefs690log <- extractor(all690pacLog, var.nms = var.nms)
## Supplementary Figure S4:
plot.extracted(coefs690log, mfrows = c(3,3), pretty.names = c("Auto Workers", "Republican", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all690pacLog, coefs690log)

## Bailout, party, dollar contribs.
all690pac <- regressAll("vote.rc110.2.690", dat = adat, model = "logit", alwaysInclude = c("factory.s2", "I(as.factor(party))"), covars = c("factory.s2", "I(as.factor(party))", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions"))
var.nms <- c("(Intercept)", "factory.s2", "I(as.factor(party))200", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions")
coefs690 <- extractor(all690pac, var.nms = var.nms)
## Supplementary Figure S5:
plot.extracted(coefs690, mfrows = c(3,3), pretty.names = c("Auto Workers", "Republican", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all690pac, coefs690)

## Clunkers, DW, logged Contribs.
all314pacLog <- regressAll("vote.rc111.1.314", dat = adat, model = "logit", alwaysInclude = c("factory.s1", "dwnom1"), covars = c("factory.s1", "dwnom1", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log"))
var.nms <- c("(Intercept)", "factory.s1", "dwnom1", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log")
coefs314log <- extractor(all314pacLog, var.nms = var.nms)
## Supplementary Figure S6:
plot.extracted(coefs314log, mfrows = c(3,3), pretty.names = c("Auto Workers", "Ideology", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all314pacLog, coefs314log)

## Clunkers, DW, dollar contribs.
all314pac <- regressAll("vote.rc111.1.314", dat = adat, model = "logit", alwaysInclude = c("factory.s1", "dwnom1"), covars = c("factory.s1", "dwnom1", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions"))
var.nms <- c("(Intercept)", "factory.s1", "dwnom1", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions")
coefs314 <- extractor(all314pac, var.nms = var.nms)
## ## Supplementary Figure S7:
plot.extracted(coefs314, mfrows = c(3,3), pretty.names = c("Auto Workers", "Ideology", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all314pac, coefs314)

## Clunkers, party, logged Contribs.
all314pacLog <- regressAll("vote.rc111.1.314", dat = adat, model = "logit", alwaysInclude = c("factory.s1", "I(as.factor(party))"), covars = c("factory.s1", "I(as.factor(party))", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log"))
var.nms <- c("(Intercept)", "factory.s1", "I(as.factor(party))200", "Total.FordDCGM.log", "Total.AFL.CIO.log", "Total.AutomotiveFree.log", "Total.Dealers.log", "Total.DealersForeign.log", "Total.AutoDealersandDrivers.log", "Total.TransUnion.log")
coefs314log <- extractor(all314pacLog, var.nms = var.nms)
## Supplementary Figure S8:
plot.extracted(coefs314log, mfrows = c(3,3), pretty.names = c("Auto Workers", "Republican", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all314pacLog, coefs314log)

## Clunkers, party, dollar contribs.
all314pac <- regressAll("vote.rc111.1.314", dat = adat, model = "logit", alwaysInclude = c("factory.s1", "I(as.factor(party))"), covars = c("factory.s1", "I(as.factor(party))", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions"))
var.nms <- c("(Intercept)", "factory.s1", "I(as.factor(party))200", "Total.FordDCGM", "Total.AFL.CIO", "Total.AutomotiveFree", "Total.Dealers", "Total.DealersForeign", "Total.AutoDealersandDrivers", "Total.TransUnions")
coefs314 <- extractor(all314pac, var.nms = var.nms)
## Supplementary Figure S9:
plot.extracted(coefs314, mfrows = c(3,3), pretty.names = c("Auto Workers", "Republican", "Big 3 PAC", "AFL-CIO PAC", "AFIT PAC", "Dealers PAC", "F Dealers PAC", "ADD PAC", "Tr. Union PAC"))

rm(all314pac, coefs314)

rm(var.nms)
